<template>
	<!-- 矿风险清单 -->
	<view class="">
		<u-navbar title="矿风险清单" :placeholder="true" leftIconColor="#fff" @rightClick="openPopup"
			titleStyle="color: #fff" bgColor="#2172FC" :autoBack="true">
			<template #right>
				<u-icon name="hourglass" color="#fff" size="25"></u-icon>
			</template>
		</u-navbar>
	</view>
	<view class="p-10">
		<template v-if="list.length > 0">
			<view class="card" v-for="(item,index) in list" @click="goDetail(item)">
				<view class="flex m-between">
					<view class="name fw">
						{{item.riskLocationName}}
					</view>
					<view class="grade fw"> 风险等级: {{item.riskLevelName}}
					</view>
				</view>
				<view class="flex m-between m-t-8">
					<view class="post"> 项目: {{item.projectInfo}}
					</view>
					<view class="pro"> 风险值: {{ item.riskValue}}
					</view>
				</view>
				<view class="flex m-between m-t-8"> 风险描述: <up-text :lines="2" :text="item.remark"></up-text>
				</view>
			</view>
		</template>
		<u-empty v-else mode="data">
		</u-empty>
	</view>
	<!-- 筛选popup -->
	<my-popup :show="showPopup" :queryParams="queryParams" :formItem="formData" @close="closePopup" @reset="reset"
		@submit="submit"></my-popup>
	<u-back-top :scroll-top="scrollTop" top="600"></u-back-top>
</template>
<script setup>
	import {
		onShow,
	} from '@dcloudio/uni-app'
	import {
		reactive,
		computed
	} from "vue";
	import {
		pageRiskData,
	} from '@/api/riskcontrol.js'
	import useList from '@/hooks/useList.js'

	let queryParams = reactive({
			needCount: 1,
			pageNum: 1,
			pageSize: 10
		}),
		formData = computed(() => {
			return [{
				itemType: 'select',
				list: checkList.value,
				label: '风险点',
				prop: 'riskLocationId'
			}, {
				itemType: 'select',
				type: 'GETdangerPoint',
				label: '危险因素',
				prop: 'dangerPoint'
			}, {
				itemType: 'select',
				type: 'GETriskLevel',
				label: '风险等级',
				prop: 'riskLevel'
			}, {
				itemType: 'select',
				type: 'GETidentifyActivityType',
				label: '辨识活动类型',
				prop: 'identifyActivityType'
			}, {
				itemType: 'date',
				type: 'daterange',
				label: '录入时间',
				prop: 'time'
			}]
		})
	// 查询
	const submit = () => {
		if (queryParams.time) {
			queryParams.startTime = queryParams.time[0]
			queryParams.endTime = queryParams.time[1]
		}
		getListData()
	}
	const {
		getListData,
		list,
		scrollTop,
		getCheckPonit,
		checkList,
		showPopup,
		openPopup,
		closePopup,
		reset
	} = useList({
		queryParams,
		api: {
			page: pageRiskData
		}
	})
	// 跳转详情
	const goDetail = (item) => {
		uni.navigateTo({
			url: '/pages/professional/risk/list/detail?data=' + JSON.stringify(item)
		})
	}
	onShow(() => {
		getCheckPonit()
		getListData()
	})
</script>
<style lang="scss" scoped>
</style>